#include <stdio.h>
#include <stdlib.h>

/** @def MAX 105
 * Description
 */
#ifndef MAX
#define MAX 105
#endif /* END OF MAX */

struct DEVICE {
    int band;
    int price;
    int min_price;
} data[MAX][MAX];

int min (int a, int b)
{
    return a < b ? a : b;
}

int sort (struct DEVICE data[MAX][MAX], int line, int line_number)
{
    int i, j;

    /* ASC */
    for (i = 0; i < line_number - 1; i++) {
        for (j = i + 1; j < line_number; j++) {
            if (data[line][i].band > data[line][j].band) {
                struct DEVICE temp = data[line][i];
                data[line][i] = data[line][j];
                data[line][j] = temp;
            }
        }
    }

    data[line][line_number-1].min_price = data[line][line_number-1].price;
    for (i = line_number-2; i >= 0; i--) {
        data[line][i].min_price = min(
                data[line][i].price, data[line][i+1].min_price);
    }

    return 0;
}

int print_data (struct DEVICE data[MAX][MAX], int line , int line_number)
{
    int i;

    for (i = 0; i < line_number; i++) {
        printf("%d/%d/%d ",
                data[line][i].band,
                data[line][i].price,
                data[line][i].min_price);
    }
    printf("\n");

    return 0;
}

int main (int argc, char const* argv[])
{
    int n, i, j, line, num[MAX], last_min, row, col;
    double ans;

    scanf("%d %d", &n, &line);
    while (n--) {
        last_min = 65535;
        for (i = 0; i < line; i++) {
            scanf("%d", &num[i]);
            for (j = 0; j < num[i]; j++) {
                scanf("%d %d", &data[i][j].band, &data[i][j].price);
            }
            /* sort */
            sort(data, i, num[i]);
            printf("%d\n", num[i]);
            print_data(data, i, num[i]);
            
            /* last element of line min */
            last_min = min(last_min, data[i][num[i]-1].band);
        }

        /* search */
        ans = 0;
        for (i = 0; i < line; i++) {
            for (j = 0; j < num[i] && data[i][j].band <= last_min; j++) {
                int b = data[i][j].band;
                int p = data[i][j].price;

                printf("[%d][%d]:%d--------\n", i, j, last_min);
                for (row = 0; row < line; row++) {
                    if (row != i) {
                        for (col = 0; col < num[i]; col++) {
                            if (data[row][col].band >= b) {
                                break;
                            }
                        }
                        printf("[%d][%d]%d\n", row, col,
                                data[row][col].min_price);
                        p += data[row][col].min_price;
                    }
                }
                printf("********\n");

                if (ans < 1.0 * b / p) {
                    ans = 1.0 * b / p;
                }
                printf("%d/%d/%.3lf\n", b, p, ans);
                printf("--------\n");
            }
        }

        printf("%.3lf\n", ans);
    }

    return 0;
}
